/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package checkers.web;

import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author artinshahverdian
 */
public class View {

    private Template template;
    private Map map;

    public View(final Map map,final String Path, final Configuration configuration) {
        try {
            this.map = map;
            template = configuration.getTemplate(Path);
        }
        catch (IOException ex) {
            Logger.getLogger(View.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    /**
     * @return the template
     */
    public Template getTemplate() {
        return template;
    }

    /**
     * @return the map
     */
    public Map getMap() {
        return map;
    }

    public void generateView(final PrintWriter out) throws IOException {
        try {
            template.process(map, out);
        }
        catch (TemplateException ex) {
            Logger.getLogger(View.class.getName()).log(Level.SEVERE, null, ex);
            //template error page
        }

    }
}
